package com.example.demo.day.config.learn.design.factory.x2;

import com.example.demo.day.config.learn.design.factory.x1.SuvCar;

public class MpvCarFactory implements CarFactory<MpvCar> {

    @Override
    public MpvCar create(String color) {
//        if (RED.equals(color)) {
//            return new MpvCar(color);
//        } else if (GREEN.equals(color)) {
//            return new MpvCar(color);
//        } else if (BLUE.equals(color)) {
//            return new MpvCar(color);
//        } else {
//            throw new RuntimeException("No such color: " + color);
//        }
        switch (color) {
            case RED:

            case GREEN:

            case BLUE:
                return new MpvCar(color);
            default:
                throw new RuntimeException("No such color: " + color);
        }
    }
}
